import request from './request'

// 获取推荐内容
export const getRecommendedContents = (params) => {
  return request({
    url: '/contents/recommend',
    method: 'get',
    params
  })
}

// 获取我的内容
export const getMyContents = (params) => {
  return request({
    url: '/contents/my',
    method: 'get',
    params
  })
}

// 获取内容详情
export const getContentDetail = (id) => {
  return request({
    url: `/contents/${id}`,
    method: 'get'
  })
}

// 获取内容导航（上一个/下一个）
export const getContentNavigation = (id) => {
  return request({
    url: `/contents/${id}/navigation`,
    method: 'get'
  })
}

// 发布内容
export const createContent = (formData) => {
  return request({
    url: '/contents',
    method: 'post',
    headers: {
      'Content-Type': 'multipart/form-data'
    },
    data: formData
  })
}

// 更新内容
export const updateContent = (id, data) => {
  return request({
    url: `/contents/${id}`,
    method: 'put',
    data
  })
}

// 删除内容
export const deleteContent = (id) => {
  return request({
    url: `/contents/${id}`,
    method: 'delete'
  })
}

// 搜索内容
export const searchContents = (params) => {
  return request({
    url: '/contents/search',
    method: 'get',
    params
  })
}

// 点赞/取消点赞
export const toggleLike = (contentId) => {
  return request({
    url: `/contents/${contentId}/likes`,
    method: 'post'
  })
}

// 获取点赞状态
export const getLikeStatus = (contentId) => {
  return request({
    url: `/contents/${contentId}/likes/status`,
    method: 'get'
  })
}

// 获取点赞数
export const getLikeCount = (contentId) => {
  return request({
    url: `/contents/${contentId}/likes/count`,
    method: 'get'
  })
}

// 添加评论
export const addComment = (contentId, data) => {
  return request({
    url: `/contents/${contentId}/comments`,
    method: 'post',
    data
  })
}

// 获取评论列表
export const getComments = (contentId, params) => {
  return request({
    url: `/contents/${contentId}/comments`,
    method: 'get',
    params
  })
}

// 获取评论数量
export const getCommentCount = (contentId) => {
  return request({
    url: `/contents/${contentId}/comments/count`,
    method: 'get'
  })
} 